package com.example.mobile2121606109ycg0414;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

public class Car extends RecyclerView.Adapter<Car.ViewHolder> {
    String[] cars;
    String[] bujian;
    public Car(String[] cars, String[] bujian){
        this.cars = cars;
        this.bujian = bujian;
    }

    class ViewHolder extends RecyclerView.ViewHolder {
         TextView rvItemHJ,rvItemBJ;

         public ViewHolder(@NonNull View itemView) {
             super(itemView);
             rvItemHJ = itemView.findViewById(R.id.rvItemHJ);
             rvItemBJ = itemView.findViewById(R.id.rvItemBJ);
         }
     }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View itemView = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.item_rv_main_car,parent,false);
        ViewHolder viewHolder = new ViewHolder(itemView);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        holder.rvItemHJ.setText(cars[position]);
        holder.rvItemBJ.setText(bujian[position]);
    }

    @Override
    public int getItemCount() {
        return cars.length;
    }
}
